
<%--
    Document   : oEstrategico
    Created on : 10/04/2010, 03:05:56 PM
    Author     : LAPTOP01
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://struts.apache.org/tags-bean"  prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="/tags/c" prefix="c"%>
<%@ include file="seguridad.jsp" %>
<script src="scripts/ajax.js" language="JavaScript"></script>

<html>
    <script LANGUAGE="JavaScript">



        function validando(){
            var cant = Math.floor(document.getElementById("ppto").value);
            var inicio = Math.floor(document.getElementById("inicio").value);
            var fin = Math.floor(document.getElementById("fin").value);
            var suma=0;



            for(inicio;inicio<=fin;inicio++){
                var num=Math.floor(document.getElementById("mes"+inicio+"MeATa").value);
                suma=suma+num;
            }
            if(suma==cant){
                insertar();
            }
            else{
                alert("La suma de los meses habilitados debe ser "+cant);
            }

        }


        function editarT(pk,mes1,mes2,mes3,mes4,mes5,mes6,mes7,mes8,mes9,mes10,mes11,mes12){
           
            document.getElementById("opcion").value=2;
            document.getElementById("pk").value=pk;
          
            document.getElementById("mes1MeATa").value=mes1;
            document.getElementById("mes2MeATa").value=mes2;
            document.getElementById("mes3MeATa").value=mes3;
            document.getElementById("mes4MeATa").value=mes4;
            document.getElementById("mes5MeATa").value=mes5;
            document.getElementById("mes6MeATa").value=mes6;
            document.getElementById("mes7MeATa").value=mes7;
            document.getElementById("mes8MeATa").value=mes8;
            document.getElementById("mes9MeATa").value=mes9;
            document.getElementById("mes10MeATa").value=mes10;
            document.getElementById("mes11MeATa").value=mes11;
            document.getElementById("mes12MeATa").value=mes12;
         activar();
        }


        function confirmAction(){
            if (confirm("Se borrara presupuesto de Tarea  \n ¿Esta seguro de continuar? "))
                return true;
            else return false;
        }



        function confirmActionGuardar(){
            if (confirm("Se Guardara los cambios hechos en la pantalla  \n ¿Esta seguro de continuar? "))
                return true;
            else
                return false;
        }




        function eliminar(pk){

            if (confirmAction()==false) return;
            var idDiv = "divTabla";
            var metodo = "GET";
            var ppto=0;
            var tipo=3;
            var tFMe=0;
            var mes1=0;
            var mes2=0;
            var mes3=0;
            var mes4=0;
            var mes5=0;
            var mes6=0;
            var mes7=0;
            var mes8=0;
            var mes9=0;
            var mes10=0;
            var mes11=0;
            var mes12=0;
            var fkTarea = document.getElementById("fkTarea").value;
            var url = "consultasAjax/listarPTareaAct.jsp?tFMe="+tFMe+"&mes1="+mes1+"&mes2="+mes2+
                "&mes3="+mes3+"&mes4="+mes4+"&mes5="+mes5+"&mes6="+mes6+"&mes7="+mes7+
                "&mes8="+mes8+"&mes9="+mes9+"&mes10="+mes10+"&mes11="+mes11+"&mes12="+
                mes12+"&pk="+pk+"&fkTarea="+fkTarea+"&tipo="+tipo+"&ppto="+ppto;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
            activar();
        }

        function insertar(){

            if (confirmActionGuardar()==false) return;
            var tipo=document.getElementById("opcion").value;
            var pk = document.getElementById("pk").value;
            var fkTarea = document.getElementById("fkTarea").value;
            var mes1 = document.getElementById("mes1MeATa").value;
            var mes2 = document.getElementById("mes2MeATa").value;
            var mes3 = document.getElementById("mes3MeATa").value;
            var mes4 = document.getElementById("mes4MeATa").value;
            var mes5 = document.getElementById("mes5MeATa").value;
            var mes6 = document.getElementById("mes6MeATa").value;
            var mes7 = document.getElementById("mes7MeATa").value;
            var mes8 = document.getElementById("mes8MeATa").value;
            var mes9 = document.getElementById("mes9MeATa").value;
            var mes10 = document.getElementById("mes10MeATa").value;
            var mes11 = document.getElementById("mes11MeATa").value;
            var mes12 = document.getElementById("mes12MeATa").value;
            var ppto=document.getElementById("ppto").value;
            var idDiv = "divTabla";
            var metodo = "GET";
            var url = "consultasAjax/listarPTareaAct.jsp?mes1="+mes1+"&mes2="+mes2+
                "&mes3="+mes3+"&mes4="+mes4+"&mes5="+mes5+"&mes6="+mes6+"&mes7="+mes7+
                "&mes8="+mes8+"&mes9="+mes9+"&mes10="+mes10+"&mes11="+mes11+"&mes12="+
                mes12+"&pk="+pk+"&fkTarea="+fkTarea+"&tipo="+tipo+"&ppto="+ppto;

            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
            document.getElementById("opcion").value=1;

            document.getElementById("mes1MeATa").value=0;
            document.getElementById("mes2MeATa").value=0;
            document.getElementById("mes3MeATa").value=0;
            document.getElementById("mes4MeATa").value=0;
            document.getElementById("mes5MeATa").value=0;
            document.getElementById("mes6MeATa").value=0;
            document.getElementById("mes7MeATa").value=0;
            document.getElementById("mes8MeATa").value=0;
            document.getElementById("mes9MeATa").value=0;
            document.getElementById("mes10MeATa").value=0;
            document.getElementById("mes11MeATa").value=0;
            document.getElementById("mes12MeATa").value=0;
            desactivar();
           

        }





        function  mostrarTabla(){

            //   var id = document.getElementById("codMetaAPer").value;

            var idDiv = "divTabla";
            var metodo = "GET";
            var fkTarea=<%out.print(request.getParameter("pk"));%>;

            var url = "consultasAjax/listarPTareaAct.jsp?proc="+0+"&tipo="+0+"&fkTarea="+fkTarea;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);

        }





        function autoCompletarDiv(metodo,url,cadena,async,idDiv)
        {
            if( window.XMLHttpRequest )
                ajax = new XMLHttpRequest();
            else
                ajax = new ActiveXObject("Microsoft.XMLHTTP");
            ELEMENT_DIV = idDiv;
            ajax.onreadystatechange = funcionCallbackVerDiv;
            ajax.open( metodo, url, async);
            ajax.send(cadena);
        }

        function funcionCallbackVerDiv()
        {
            if( ajax.readyState == 4 )
            {
                if( ajax.status == 200 )
                { //alert(ajax.responseText);
                    document.getElementById(ELEMENT_DIV).innerHTML = ajax.responseText;
                }
            }
        }


        function validar(){
            var inicio = Math.floor(document.getElementById("inicio").value);
            var fin = Math.floor(document.getElementById("fin").value);
            for(inicio;inicio<=fin;inicio++){
                document.getElementById("mes"+inicio+"MeATa").disabled = false;
            }
            mostrarTabla();
            var flag = Math.floor(document.getElementById("flag").value);
            if(flag==0){
                activar();
            }
            if(flag==1){
                desactivar();
            }
        }
        function regresar(){

            var form = document.getElementById("PEIForm");

            var descObj=document.getElementById("descObj").value;

            var descObjEsp =document.getElementById("descObjEsp").value;

            var descActPer =document.getElementById("descActPer").value;

            var presupActPer =document.getElementById("presupActPer").value;
            var idActividad =document.getElementById("idActividad").value;

            form.action="PEI.do?dispatch=listarTareaActividad&descOEstrategico="+descObj+"&descOEspecifico="+descObjEsp+"&descActividad="+descActPer+"&ppto="+presupActPer+"&idActividad="+idActividad+"&inimes=0&finmes=0";


            form.method="post";

            form.submit();
        }

  function desactivar(){

            PEIForm.grabar.disabled = true;

        }

        function activar(){

            PEIForm.grabar.disabled = false;

        }

    </script>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="lib/css/estilos.css" type="text/css">
        <link href="lib/css/styles_pages.css" rel="stylesheet" type="text/css" />
        <title>JSP Page</title>
    </head>
    <body  onload="validar()">
        <center>
            <h1> Presupuesto de Tarea</h1></center>
        <div style="overflow: auto; width: 700px; height: 400px">
            <html:form action="PEI.do?dispatch=ingresarMetaFisica" styleId="PEIForm">
                <html:hidden property="opcion" styleId="opcion" value="1"/>
                <html:hidden property="codTActividad" styleId="fkTarea"/>
                <html:hidden property="codPpto" styleId="pk"/>
                <html:hidden property="inicio" styleId="inicio" />

            <html:hidden property="ppto" styleId="presupActPer" />
            <html:hidden property="codActPer" styleId="idActividad" />
            <html:hidden property="descObj" styleId="descObj" />
            <html:hidden property="descObjEsp" styleId="descObjEsp" />
            <html:hidden property="descActPer" styleId="descActPer" />
            <html:hidden property="fin" styleId="fin" />
            <html:hidden property="flag" styleId="flag" />

            <table border="1" cellspacing="0">

                <tr>
                    <td>Objetivo General Estrat&eacute;gico</td>
                    <td>
                        <html:textarea  styleId="descObj" property="descObj"  disabled="true" rows="5" cols="50"/>
                    </td>
                </tr>
                <tr>
                    <td>Objetivo Espec&iacute;fico Estrat&eacute;gico</td>
                    <td>
                        <html:textarea  styleId="descObjEsp" property="descObjEsp"  disabled="true" rows="5" cols="50"/>
                    </td>
                </tr>
                <tr>
                    <td>Actividad Estrat&eacute;gica</td>
                    <td>
                        <html:textarea  styleId="descActPer" property="descActPer"  disabled="true" rows="5" cols="50"/>
                    </td>
                </tr>
                <tr>
                    <td>Tarea</td>
                    <td>
                        <html:textarea  styleId="descTActividad" property="descTActividad"  disabled="true" rows="5" cols="50"/>
                    </td>
                </tr>


                <tr>
                    <td>PPTO</td>
                    <td>
                        <html:text property="ppto"  disabled="true" styleId="ppto"/>
                    </td>
                </tr>

            </table>
            <table border="1" cellspacing="0">
                <tr>
                    <td>Enero:</td>
                    <td><html:text  styleId="mes1MeATa" property="mes1MeATa" maxlength="400" disabled="true"/></td>
                    <td>Febrero:</td>
                    <td><html:text  styleId="mes2MeATa" property="mes2MeATa" maxlength="400" disabled="true"/></td>
                    <td>Marzo:</td>
                    <td><html:text  styleId="mes3MeATa" property="mes3MeATa" maxlength="400" disabled="true"/></td>
                    <td>Abril:</td>
                    <td><html:text  styleId="mes4MeATa" property="mes4MeATa" maxlength="400" disabled="true"/></td>
                </tr>
                <tr>
                    <td>Mayo:</td>
                    <td><html:text  styleId="mes5MeATa" property="mes5MeATa" maxlength="400" disabled="true"/></td>
                    <td>Junio:</td>
                    <td><html:text  styleId="mes6MeATa" property="mes6MeATa" maxlength="400" disabled="true"/></td>
                    <td>Julio:</td>
                    <td><html:text  styleId="mes7MeATa" property="mes7MeATa" maxlength="400" disabled="true"/></td>
                    <td>Agosto:</td>
                    <td><html:text  styleId="mes8MeATa" property="mes8MeATa" maxlength="400" disabled="true"/></td>
                </tr>
                <tr>
                    <td>Setiembre:</td>
                    <td><html:text  styleId="mes9MeATa" property="mes9MeATa" maxlength="400" disabled="true"/></td>
                    <td>Octubre:</td>
                    <td><html:text  styleId="mes10MeATa" property="mes10MeATa" maxlength="400" disabled="true"/></td>
                    <td>Noviembre:</td>
                    <td><html:text  styleId="mes11MeATa" property="mes11MeATa" maxlength="400" disabled="true"/></td>
                    <td>Diciembre:</td>
                    <td><html:text  styleId="mes12MeATa" property="mes12MeATa" maxlength="400" disabled="true"/></td>
                </tr>
                <tr>
                        <td colspan="3">
                            <label style="color: blue"> Solo se permite grabar un registro en este M&oacute;dulo</label>
                        </td>
                    </tr>
                <tr><center>
                    <td colspan="2" align="center"><input type="button" id="grabar" value="Grabar" onclick="validando()"/><html:button property="button"  value="regresar" onclick="javascript: window.history. back()" /></td></center>
            </tr>
        </table>


        <div id="divTabla"  >

        </div>


    </html:form>
        </div>

</body>
</html>